classdef DataSet < BatHandle
    
    properties ( SetAccess = protected )
        dmX %= DataMatrix() % Describing features
        dmY %= DataMatrix() % Describing labels
    end
    
    properties ( SetAccess = protected, Dependent = true )
        nObs % Number of observations
        nFet % Number of features
        nLab % Number of labels
        zObsName % Observation names, which are the row names of `.dmX`
        zFetName % Feature names, which are the col names of `.dmX`
        zLabName % Label names, which are the col names of `.dmY`
    end
    
    methods % Constructor
        function [ this ] = DataSet( name, dmX, dmY )
            if nargin == 0
                this.setName('data_set');
            end
            if nargin >= 1
                this.setName(name);
            end
            if nargin == 2
                error(['BatErr: Invalid `nargin`. ', ...
                    'I.e., `.dmY` not to be assigned']);
            end
            if nargin >= 3
                this.setDmX(dmX);
                this.setDmY(dmY);
                assert(dmX.nRow == dmX.nRow);
            end
            
            if isempty(this.dmX)
                this.dmX = DataMatrix();
            end
            if isempty(this.dmY)
                this.dmY = DataMatrix();
            end
        end
    end
    
    methods % Gets ( dependent )
        function [ nObs ] = get.nObs( this )
            nObs = this.dmX.nRow;
        end
        
        function [ nFet ] = get.nFet( this )
            nFet = this.dmX.nCol;
        end
        
        function [ nLab ] = get.nLab( this )
            nLab = this.dmY.nCol;
        end
        
        function [ zObsName ] = get.zObsName( this )
            % The observation names are the row names of $.dmX$.
            zObsName = this.dmX.getZRowName();
        end
        
        function [ zFetName ] = get.zFetName( this )
            % The feature names are the col names of $.dmX$.
            zFetName = this.dmX.getZColName();
        end
        
        function [ zLabName ] = get.zLabName( this )
            % The label names are the col names of $.dmY$.
            zLabName = this.dmY.getZColName();
        end
    end
    
    methods % Gets
    end
end
